/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fjut.se1603.springmvc.dao;

import edu.fjut.se1603.springmvc.entity.SysUser;
import org.apache.ibatis.jdbc.SQL;

/**
 *
 * @author danny
 */
public class SysUserDaoSqlProvider {
    public String selectByExample(SysUser user) {
        SQL sql = new SQL();
        sql.SELECT("*").FROM("sys_user");
        if (user.getAccount() != null) {
            user.setAccount(user.getAccount() + "%");
            sql.WHERE("ACCOUNT like #{account}");
        }
        if (user.getMobile() != null) {
            sql.WHERE("MOBILE=#{mobile}");
        }
        if (user.getEmail() != null) {
            sql.WHERE("EMAIL=#{email}");
        }
        if (user.getUserName() != null) {
            user.setUserName(user.getUserName() + "%");
            sql.WHERE("USER_NAME like #{userName}");
        }
        return sql.toString();
    }
}
